package com.wangjie.simple;

import java.util.HashSet;
import java.util.Set;

/**
 * @author jieshao
 * @date 2022/5/27 11:10
 *
 * 217. 存在重复元素
 */
public class Test04 {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4};
        boolean res = containsDuplicate(arr);
        System.out.println(res);
    }

    public static boolean containsDuplicate(int[] nums) {
        Set<Integer> set = new HashSet<>();
        for (int t : nums) {
            if (!set.add(t)) {
                return true;
            }
        }
        return false;
    }
}